<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Dslash &mdash; SIMULATeQCD 0.7 documentation</title>
      <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
      <link rel="stylesheet" href="../_static/togglebutton.css" type="text/css" />
      <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/togglebutton.js"></script>
        <script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
        <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
        <script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
    <script src="../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Integrator" href="integrator.html" />
    <link rel="prev" title="Gauge Updates (HB and OR)" href="gaugeUpdates.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #343131" >
            <a href="../index.html" class="icon icon-home"> SIMULATeQCD
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../01_gettingStarted/gettingStarted.html">Getting started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../02_contributions/contributions.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../03_applications/applications.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../04_codeBase/codeBase.html">Code base</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Modules</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="inverter.html">Inverter (Conjugate Gradient)</a></li>
<li class="toctree-l2"><a class="reference internal" href="correlator.html">Correlator Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="gaugeUpdates.html">Gauge Updates (HB and OR)</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Dslash</a></li>
<li class="toctree-l2"><a class="reference internal" href="integrator.html">Integrator</a></li>
<li class="toctree-l2"><a class="reference internal" href="randomNumbers.html">Random Number Generator</a></li>
<li class="toctree-l2"><a class="reference internal" href="gaugeSmearing.html">HISQ smearing</a></li>
</ul>
</li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu"  style="background: #343131" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">SIMULATeQCD</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
          <li><a href="modules.html">Modules</a> &raquo;</li>
      <li>Dslash</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../_sources/05_modules/dslash.md.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section class="tex2jax_ignore mathjax_ignore" id="dslash">
<h1>Dslash<a class="headerlink" href="#dslash" title="Permalink to this headline"></a></h1>
<p>This module implements the Dslash operator for staggered and highly improved staggered quark (HISQ) fermions. It is a sparse matrix-vector product that is implemented as a 4 dimensional stencil kernel with nearest and third-nearest neighbor terms. For HISQ fermions, the matrix-vector product takes the form
<span class="math notranslate nohighlight">\(
\begin{align}
D[U]\psi_{x}&amp;=\sum_{\mu=0}^{4}\left[c_{1}\left(V_{x,\mu}\psi_{x+\hat{\mu}}-V^{\dagger}_{x-\hat{\mu},\mu}\psi_{x-\hat{\mu}}\right)+c_{3}\left(W_{x,\mu}\psi_{x+3\hat{\mu}}-W^{\dagger}_{x-3\hat{\mu},\mu}\psi_{x-3\hat{\mu}}\right)\right],
\end{align}\)</span>
where <span class="math notranslate nohighlight">\(V_{x,\mu}\)</span> and <span class="math notranslate nohighlight">\(W_{x,\mu}\)</span> are the HISQ smeared fields described in <a class="reference external" href="https://latticeqcd.github.io/SIMULATeQCD/05_modules/08_gaugeSmearing.html">Hisq Smearing</a>.
For staggered fermions, only the nearest neighbor term is present and the basic gauge field <span class="math notranslate nohighlight">\(U_{x,\mu}\)</span> is used in place of <span class="math notranslate nohighlight">\(V_{x,\mu}\)</span>.</p>
<p>In the code, Dslash operators are derived from an abstract base class that defines the interface for Dslash operators.</p>
<div class="highlight-C++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="nc">SpinorLHS_t</span><span class="p">,</span><span class="w"> </span><span class="k">typename</span> <span class="nc">SpinorRHS_t</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">class</span> <span class="nc">DSlash</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="n">LinearOperator</span><span class="o">&lt;</span><span class="n">SpinorRHS_t</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="k">public</span><span class="o">:</span><span class="w"></span>
<span class="w">    </span><span class="k">virtual</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="n">Dslash</span><span class="p">(</span><span class="n">SpinorLHS_t</span><span class="w"> </span><span class="o">&amp;</span><span class="n">lhs</span><span class="p">,</span><span class="w"> </span><span class="n">SpinorRHS_t</span><span class="w"> </span><span class="o">&amp;</span><span class="n">rhs</span><span class="p">,</span><span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="n">update</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">true</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">virtual</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="nf">applyMdaggM</span><span class="p">(</span><span class="n">SpinorRHS_t</span><span class="w"> </span><span class="o">&amp;</span><span class="p">,</span><span class="w"> </span><span class="n">SpinorRHS_t</span><span class="w"> </span><span class="o">&amp;</span><span class="p">,</span><span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="n">update</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">true</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</pre></div>
</div>
<p>The method <code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">Dslash(SpinorLHS_t</span> <span class="pre">&amp;lhs,</span> <span class="pre">SpinorRHS_t</span> <span class="pre">&amp;rhs,</span> <span class="pre">bool</span> <span class="pre">update</span> <span class="pre">=</span> <span class="pre">true)</span></code> applies the stencil operator described above to an input vector <code class="docutils literal notranslate"><span class="pre">rhs</span></code> and write the result into the vector <code class="docutils literal notranslate"><span class="pre">lhs</span></code>.</p>
<p><span class="math notranslate nohighlight">\(\begin{align}
\chi=D\psi
\end{align}\)</span></p>
<p>The method <code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">applyMdaggM(SpinorRHS_t</span> <span class="pre">&amp;lhs,</span> <span class="pre">SpinorRHS_t</span> <span class="pre">&amp;rhs,</span> <span class="pre">bool</span> <span class="pre">update</span> <span class="pre">=</span> <span class="pre">true)</span></code> computes</p>
<p><span class="math notranslate nohighlight">\(\begin{align}
\chi=M^{\dagger}M\psi \;\;\;\mathrm{where} \;\;M[U]=D[U]+m_{f},
\end{align}\)</span></p>
<p>and <span class="math notranslate nohighlight">\(m_{f}\)</span> is the quark mass. In both methods, <code class="docutils literal notranslate"><span class="pre">bool</span> <span class="pre">update</span></code> toggles wether or not a halo update should be performed on the output spinor after the kernel is applied.</p>
<p>The derived class for HISQ fermions is:</p>
<div class="highlight-C++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="nc">floatT</span><span class="p">,</span><span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="n">onDevice</span><span class="p">,</span><span class="w"> </span><span class="n">Layout</span><span class="w"> </span><span class="n">LatLayoutRHS</span><span class="p">,</span><span class="w"> </span><span class="kt">size_t</span><span class="w"> </span><span class="n">HaloDepthGauge</span><span class="p">,</span><span class="w"> </span><span class="kt">size_t</span><span class="w"> </span><span class="n">HaloDepthSpin</span><span class="p">,</span><span class="w"> </span><span class="kt">size_t</span><span class="w"> </span><span class="n">NStacks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">class</span> <span class="nc">HisqDSlash</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="n">DSlash</span><span class="o">&lt;</span><span class="n">Spinorfield</span><span class="o">&lt;</span><span class="n">floatT</span><span class="p">,</span><span class="w"> </span><span class="n">onDevice</span><span class="p">,</span><span class="w"> </span><span class="n">LayoutSwitcher</span><span class="o">&lt;</span><span class="n">LatLayoutRHS</span><span class="o">&gt;</span><span class="p">(),</span><span class="w"> </span><span class="n">HaloDepthSpin</span><span class="p">,</span><span class="w"> </span><span class="n">NStacks</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">Spinorfield</span><span class="o">&lt;</span><span class="n">floatT</span><span class="p">,</span><span class="w"> </span><span class="n">onDevice</span><span class="p">,</span><span class="w"> </span><span class="n">LatLayoutRHS</span><span class="p">,</span><span class="w"> </span><span class="n">HaloDepthSpin</span><span class="p">,</span><span class="w"> </span><span class="n">NStacks</span><span class="o">&gt;</span><span class="w"> </span><span class="o">&gt;</span><span class="w"></span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">floatT</span></code> specifies which floating point type to use and <code class="docutils literal notranslate"><span class="pre">onDevice</span></code> toggles whether or not gauge and spinor fields are residing on the host or device. The template parameter <code class="docutils literal notranslate"><span class="pre">Layout</span> <span class="pre">LatLayoutRHS</span></code> specifies the lattice layout of the input vector and can take the values <code class="docutils literal notranslate"><span class="pre">Even</span></code> <code class="docutils literal notranslate"><span class="pre">Odd</span></code> and <code class="docutils literal notranslate"><span class="pre">All</span></code>. <code class="docutils literal notranslate"><span class="pre">HaloDepthGauge</span></code> and <code class="docutils literal notranslate"><span class="pre">HaloDepthSpin</span></code> specify the depth of the halo buffers needed for multi-gpu calculations. Usually, <code class="docutils literal notranslate"><span class="pre">HaloDepthGauge=2</span></code> and <code class="docutils literal notranslate"><span class="pre">HaloDepthSpin=4</span></code> should be chosen.
The last template parameter <code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">NStacks</span></code> specifies how many rhs vectors are used simultaneously. Loading a gauge link once and multiplying it to multiple vectors within the same kernel call significantly increases performance as the DSlash kernels performance is mostly bandwidth bound.
A HisqDSlash object is constructed with:</p>
<div class="highlight-C++ notranslate"><div class="highlight"><pre><span></span><span class="n">HisqDSlash</span><span class="p">(</span><span class="n">Gauge_t</span><span class="o">&lt;</span><span class="n">R18</span><span class="o">&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="n">gaugefield_smeared</span><span class="p">,</span><span class="w"> </span><span class="n">Gauge_t</span><span class="o">&lt;</span><span class="n">U3R14</span><span class="o">&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="n">gaugefield_Naik</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">mass</span><span class="p">,</span><span class="w"> </span><span class="n">floatT</span><span class="w"> </span><span class="n">naik_epsilon</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"></span>
<span class="w">               </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">spinorName</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;SHARED_HisqDSlashSpinor&quot;</span><span class="p">)</span><span class="w"></span>
</pre></div>
</div>
<p>Here <code class="docutils literal notranslate"><span class="pre">gaugefield_smeared</span></code> refers to <span class="math notranslate nohighlight">\(V_{x,\mu}\)</span> and <code class="docutils literal notranslate"><span class="pre">gaugefield_Naik</span></code> to <span class="math notranslate nohighlight">\(W_{x,\mu}\)</span>. Note the different compression types for the gauge fields: the field entering the third-nearest neighbor hopping term uses <code class="docutils literal notranslate"><span class="pre">CompressionType</span> <span class="pre">comp=U3R14</span></code> in order to save memory bandwidth. <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">double</span> <span class="pre">mass</span></code> specifies the quark mass that enters <code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">MdaggM</span></code> and <code class="docutils literal notranslate"><span class="pre">floatT</span> <span class="pre">naik_epsilon</span></code> specifies the coefficient <span class="math notranslate nohighlight">\(\epsilon\)</span> that can be included in the Naik term. The last parameter that can be given to the constructor is a string identifiying the memory allocated for a temporary spinor that is used internally. By default multiple instances of HisqDslash will share the same memory for this temporary spinor. See the documentation on <code class="docutils literal notranslate"><span class="pre">MemoryManagement</span></code> for further information.</p>
</section>


           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, LatticeQCD.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>